Skip to main content

Components Layer

The components layer contains reusable UI components

Details

  • 📁 Absolute Path: @c
  • 📁 Folder Location: src/components

Layer Import and Usage Rules

Actionbasecomponentslibsmodulesviewsappservices
📥 Can Import From
📤 Can Export To

Key:

  • Allowed: The layer can import from or export to the specified layer.
  • Not Allowed: The layer cannot import from or export to the specified layer.

The components layer contains reusable UI components that are shared across the project. These components are independent and can be used in modules and views , app layers of the application. The components layer is responsible for defining the visual elements of the application, such as buttons, forms, modals, and more.

1. Purpose of the components Layer

The components layer is responsible for:

  • Providing reusable UI components that are used across the entire project.
  • Ensuring consistency in design and behavior.
  • Reducing code duplication by centralizing shared UI elements.
  • Supporting customization through props and theming.

2. Structure of the components Layer

   src/
└── components/
├── Button.tsx # Button component
├── Input.tsx # Input component
├── Card.tsx # Card component
├── Modal.tsx # Modal component
├── Navbar.tsx # Navbar component

3. Usage of the components Layer

The components layer can be used to define reusable UI components that are shared across the entire project. It is independent and can be imported.

src/components/Button.tsx
import React from "react";
import styles from "./Button.module.css";
import { ButtonTypes } from "./types";

const button = (props: ButtonTypes) => {
return <button className={styles.button}>Click Me</button>;
}

export default button;
src/app/index.tsx
import { button } from "@c/Button";

function App() {
return (
<div>
<Button/>
</div>
);
}

4. Files in the components Layer

The components layer contains the following files:

  • the UI-specific components like Tabs, Dropdown, Accordion, etc.
  • common components like TextInput, Select, Checkbox, Radio, etc.